package com.androidx.p013lv.mine.activity;

import android.view.View;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.androidx.p013lv.base.view.StatusControlLayout;
import com.androidx.p013lv.mine.C1207R;
import com.androidx.p013lv.mine.adapter.ProxyDetailAdapter;
import com.androidx.p013lv.mine.bean.WalletHistoryBean;
import com.androidx.p013lv.mine.databinding.ActivityProxyDetailsLayoutBinding;
import com.androidx.p013lv.mine.model.ProxyViewModel;
import com.gyf.immersionbar.ImmersionBar;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
import java.util.List;

/* renamed from: com.androidx.lv.mine.activity.ProxyDetailsActivity */
public class ProxyDetailsActivity extends BaseActivity<ActivityProxyDetailsLayoutBinding> implements OnRefreshLoadMoreListener {
    private ProxyDetailAdapter adapter;
    private String createdAt = "";
    private ProxyViewModel model;

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityProxyDetailsLayoutBinding) this.binding).toolbar).init();
    }

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return C1207R.C1212layout.activity_proxy_details_layout;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        this.model = (ProxyViewModel) new ViewModelProvider(this).get(ProxyViewModel.class);
        ((ActivityProxyDetailsLayoutBinding) this.binding).setClick(new OnClick());
        this.adapter = new ProxyDetailAdapter();
        ((ActivityProxyDetailsLayoutBinding) this.binding).include.recycler.setLayoutManager(new LinearLayoutManager(this));
        ((ActivityProxyDetailsLayoutBinding) this.binding).include.recycler.setAdapter(this.adapter);
        ((ActivityProxyDetailsLayoutBinding) this.binding).include.refresh.setOnRefreshListener(this);
        ((ActivityProxyDetailsLayoutBinding) this.binding).include.refresh.setOnLoadMoreListener(this);
        ((ActivityProxyDetailsLayoutBinding) this.binding).include.statusLayout.setOnRetryListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.mine.activity.ProxyDetailsActivity.View$OnClickListenerC12621 */

            public void onClick(View view) {
                ProxyDetailsActivity.this.createdAt = "";
                ((ActivityProxyDetailsLayoutBinding) ProxyDetailsActivity.this.binding).setStatus(2);
                ProxyDetailsActivity.this.model.getProxyDetails(ProxyDetailsActivity.this.createdAt);
            }
        });
        this.model.dataProxyDetails().observe(this, new Observer<BaseRes<List<WalletHistoryBean>>>() {
            /* class com.androidx.p013lv.mine.activity.ProxyDetailsActivity.C12632 */

            public void onChanged(BaseRes<List<WalletHistoryBean>> baseRes) {
                ProxyDetailsActivity.this.hideLoading();
                if (baseRes.getCode() == 200) {
                    List<WalletHistoryBean> data = baseRes.getData();
                    if (ProxyDetailsActivity.this.createdAt.equals("")) {
                        if (data == null || data.size() == 0) {
                            ((ActivityProxyDetailsLayoutBinding) ProxyDetailsActivity.this.binding).setStatus(4);
                            return;
                        }
                        ProxyDetailsActivity.this.adapter.setData(data);
                        ProxyDetailsActivity.this.createdAt = data.get(data.size() - 1).getCreatedAt();
                        if (data.size() < 30) {
                            ((ActivityProxyDetailsLayoutBinding) ProxyDetailsActivity.this.binding).setStatusRefresh(2);
                        }
                    } else if (data == null || data.size() == 0) {
                        ((ActivityProxyDetailsLayoutBinding) ProxyDetailsActivity.this.binding).setStatusRefresh(2);
                    } else {
                        ProxyDetailsActivity.this.adapter.setDatasInEnd(data);
                        ProxyDetailsActivity.this.createdAt = data.get(data.size() - 1).getCreatedAt();
                        if (data.size() < 30) {
                            ((ActivityProxyDetailsLayoutBinding) ProxyDetailsActivity.this.binding).setStatusRefresh(2);
                        }
                    }
                } else if (ProxyDetailsActivity.this.createdAt.equals("")) {
                    ((ActivityProxyDetailsLayoutBinding) ProxyDetailsActivity.this.binding).setStatus(1);
                } else {
                    ToastUtils.getInstance().showWrong(baseRes.getMsg());
                }
            }
        });
        ((ActivityProxyDetailsLayoutBinding) this.binding).setStatus(2);
        this.model.getProxyDetails(this.createdAt);
    }

    @Override // com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
    public void onLoadMore(RefreshLayout refreshLayout) {
        this.model.getProxyDetails(this.createdAt);
    }

    @Override // com.scwang.smartrefresh.layout.listener.OnRefreshListener
    public void onRefresh(RefreshLayout refreshLayout) {
        this.createdAt = "";
        this.model.getProxyDetails("");
    }

    public void hideLoading() {
        ((ActivityProxyDetailsLayoutBinding) this.binding).setStatus(0);
        ((ActivityProxyDetailsLayoutBinding) this.binding).setStatusRefresh(1);
    }

    public static void showStatusView(StatusControlLayout statusControlLayout, int i) {
        statusControlLayout.showStatusView(i);
    }

    public static void refreshStatus(SmartRefreshLayout smartRefreshLayout, int i) {
        if (i == 1) {
            smartRefreshLayout.finishLoadMore();
            smartRefreshLayout.finishRefresh();
        }
        if (i == 2) {
            smartRefreshLayout.finishLoadMore(0, true, true);
        }
    }

    /* renamed from: com.androidx.lv.mine.activity.ProxyDetailsActivity$OnClick */
    public class OnClick {
        public OnClick() {
        }

        public void btnBack() {
            ProxyDetailsActivity.this.finish();
        }

        public void proxyRules() {
            if (!ProxyDetailsActivity.this.isOnClick()) {
                ARouter.getInstance().build(Constance.PROXY_RULE_ACTIVITY).navigation();
            }
        }
    }
}
